home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Resource for Source: C/C++
/
Resource for Source - C-C++.iso
/
codelib6
/
v_08_10
/
8n10086a
< prev
next >
Wrap
Text File
|
1995-11-01
|
1KB
|
54 lines
Listing 2:
#include <stdio.h>
main()
{
int iInteger;
char cChar1, cChar2;
typedef union stuff
{
int iInt;
char cChar[2];
} uSTUFF;
uSTUFF uStuff;
iInteger = 0XFFFF;
cChar1 = 'A'; /* OX41 in ASCII Char Set */
cChar2 = 'B'; /* OX42 in ASCII Char Set */
printf ("\nstuff(): raw iInteger value is %x",
iInteger);
uStuff.iInt = iInteger;
printf ("\nstuff(): uStuff integer value is %x",
uStuff.iInt);
uStuff.cChar [0] = cChar1;
printf ("\nstuff(): uStuff integer value is %x",
uStuff.iInt);
uStuff.cChar[1] = cChar2;
printf ("\nstuff(): uStuff integer value is %x",
uStuff.iInt);
}
Output from above stuff() program:
èstuff(): raw iInteger value is ffff
stuff(): uStuff integer value is ffff
stuff(): uStuff integer value is ff41
stuff(): uStuff integer value is 4241
************